package com.zy.service.impl;

import java.util.List;

import com.zy.dao.CustomerDao;
import com.zy.dao.impl.CustomerDaoImpl;
import com.zy.entity.Customer;
import com.zy.entity.CustomerEx;
import com.zy.entity.Dict;
import com.zy.service.CustomerService;
import com.zy.utils.LimitUtil;

public class CustomerServiceImpl implements CustomerService{

	//创建dao层对象
	CustomerDao cd=new  CustomerDaoImpl();
	
	@Override
	public List<Dict> getDict() {
	
		return cd.getDict();
	}

	@Override
	public LimitUtil getCustomerInfo(int currentPage) {
	//得到 m,n
	LimitUtil limitUtil = new LimitUtil();//不饱满，未把属性填充完整
	limitUtil.setCurrentPage(currentPage);
	int m=(currentPage-1)*limitUtil.getPageSize();
	int n=limitUtil.getPageSize();		
	List<Customer> customers = cd.getCustomers(m, n);
	//把limitUtil中未赋值的属性赋值
	limitUtil.setTotalCount(cd.getTotalCount());
	limitUtil.setData(customers);

	return limitUtil;//经过以上赋值，limitUtil拥有页面所需要的一些信息，把它返回出去
	}

	@Override
	public Customer getCustomerById(int cid) {
		
		return cd.getCustomer(cid);
	}

	@Override
	public void updateCustomer(Customer customer) {
		cd.updateCustomer(customer);
		
	}

	@Override
	public void insertCustomer(Customer customer) {
		cd.insertCustomer(customer);
		
	}

	@Override
	public void deleteCustomer(int cid) {
		cd.deleteCustomer(cid);
		
	}

	@Override
	public List<Customer> selectAllCustomer() {
		
		return cd.selectAllCustomer();
	}

	@Override
	public List<Customer> queryByName(String name) {
		
		return cd.queryByName(name);
	}

	@Override
	public List<Customer> getCustomernl(String custname, int custlevel) {
		// TODO Auto-generated method stub
		return cd.getCustomernl(custname, custlevel);
	}

	@Override
	public List<Customer> getCustomerls(int custlevel, String custsource) {
		// TODO Auto-generated method stub
		return cd.getCustomerls(custlevel, custsource);
	}

	@Override
	public List<Customer> getCustomernls(String custname, int custlevel, String custsource) {
		// TODO Auto-generated method stub
		return cd.getCustomernls(custname, custlevel, custsource);
	}

	@Override
	public List<Customer> getCustomernll(int custlevel) {
		// TODO Auto-generated method stub
		return cd.getCustomernll(custlevel);
	}

	@Override
	public List<CustomerEx> getCS() {
		return cd.getCS();
	}

	@Override
	public List<CustomerEx> getCP() {
		
		return cd.getCP();
	}

}
